package com.neusoft.controller;

import com.neusoft.base.BaseController;
import com.neusoft.model.UserSearch;
import com.neusoft.po.Manage;
import com.neusoft.service.ManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/manage")
@Api(tags = "管理者用户接口")
public class ManageController extends BaseController {

    @Resource
    private ManageService manageService;

    @PostMapping("/page")
    @ApiOperation("管理者用户集合")
    public Object page(@RequestBody UserSearch userSearch) {
        return manageService.page(userSearch);
    }

    @GetMapping
    @ApiOperation("单个用户详细消息")
    @ApiImplicitParam(value = "评论ID", name = "id", required = true)
    public Manage get(Integer id) {
        return manageService.getById(id);
    }

    @PostMapping
    @ApiOperation("单条用户注册")
    public Integer save(@RequestBody Manage user) {
        return manageService.save(user);
    }

    @DeleteMapping("/{ids}")
    @ApiOperation("多个用户删除")
    public Integer delete(@PathVariable("ids") Integer[] ids) {
        manageService.deleteByIds(ids);
        return ids.length;
    }
}
